package com.xhapi.controller;

import com.xhapi.pojo.dto.TranslateDTO;
import com.xhapi.pojo.entity.ApiResult;
import com.xhapi.service.TranslateService;
import com.xhapi.utils.ApiResultHandler;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/tran")
@RequiredArgsConstructor
public class TranslateController {
    private final TranslateService translateService;

    @GetMapping
    public ApiResult translate(@RequestBody TranslateDTO translateDTO) throws Exception {
        String text=translateService.translate(translateDTO.getFrom(),translateDTO.getTo(),translateDTO.getText());
        return ApiResultHandler.success();
    }

}
